import 'package:adjust_sdk/adjust.dart';
import 'package:adjust_sdk/adjust_config.dart';
import 'package:adjust_sdk/adjust_event_failure.dart';
import 'package:adjust_sdk/adjust_event_success.dart';
import 'package:flutter/foundation.dart';

import 'common/config.dart';

class Env {
  Env._();

  // Platform messages are asynchronous, so we initialize in an async method.
  static Future<void> initPlatformState() async {
    AdjustEnvironment env;
    AdjustLogLevel logLevel;
    if (kDebugMode) {
      env = AdjustEnvironment.sandbox;
      logLevel = AdjustLogLevel.verbose;
    } else {
      env = AdjustEnvironment.production;
      logLevel = AdjustLogLevel.suppress;
    }
    final AdjustConfig config = AdjustConfig(SDK.kAdjustAppId, env);
    config.logLevel = logLevel;

    config.eventSuccessCallback = (AdjustEventSuccess eventSuccessData) {
      debugPrint('[Adjust]: Event tracking success!');
    };

    config.eventFailureCallback = (AdjustEventFailure eventFailureData) {
      debugPrint('[Adjust]: Event tracking failure!');
    };

    // COPPA compliance.
    // config.coppaCompliantEnabled = true;

    // Google Play Store kids apps.
    // config.playStoreKidsAppEnabled = true;

    // Start SDK.
    Adjust.start(config);
  }
}
